{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "2346834d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "# P67处理seq types代码\n",
    "phrase = \"Don't panic!\"\n",
    "plist = list(phrase)  # 把字符串转变为 list ： list(str)\n",
    "print(phrase)\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ab0a62d4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# pop() 按index索引删除 如果不填=>则删除末位     对应的记忆==>append()增加末位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "392f8186",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a']\n"
     ]
    }
   ],
   "source": [
    "# 循环4次 进行四次plist的pop()方法操作，即删除4次末位\n",
    "for i in range(4):\n",
    "    plist.pop()\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "f5ebe727",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "plist.pop(0)\n",
    "plist.remove(\"'\")\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "a6b0a038",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', 't', ' ', 'p', 'a', 'n', 'i', '!', 'c']\n",
      "['o', 'n', ' ', 't', 'p', 'a', 'n', 'i', '!', 'c']\n"
     ]
    }
   ],
   "source": [
    "plist.extend([plist.pop(),plist.pop()])\n",
    "print(plist)\n",
    "# 删除 位置3的 ‘ ’ 并且插入到  位置 2\n",
    "plist.insert(2,plist.pop(3))\n",
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "13ae108e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "plist= ['o', 'n', ' ', 't', 'p', 'a', 'n', 'i', '!', 'c']\n",
      "new_phrase= on tpani!c\n"
     ]
    }
   ],
   "source": [
    "new_phrase = ''.join(plist) # 列表元素的合并\n",
    "print(\"plist=\",plist)\n",
    "print(\"new_phrase=\",new_phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13a02306",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
